/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.mto.module.karaoke.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.util.PortalUtil;

import com.mto.module.karaoke.service.UserSongsLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author vuonglm
 */
public class UserSongsClp extends BaseModelImpl<UserSongs> implements UserSongs {
	public UserSongsClp() {
	}

	public Class<?> getModelClass() {
		return UserSongs.class;
	}

	public String getModelClassName() {
		return UserSongs.class.getName();
	}

	public long getPrimaryKey() {
		return _userSongId;
	}

	public void setPrimaryKey(long primaryKey) {
		setUserSongId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_userSongId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("userSongId", getUserSongId());
		attributes.put("userId", getUserId());
		attributes.put("commentNumber", getCommentNumber());
		attributes.put("listenNumber", getListenNumber());
		attributes.put("mark", getMark());
		attributes.put("recodingUrl", getRecodingUrl());
		attributes.put("description", getDescription());
		attributes.put("isShow", getIsShow());
		attributes.put("avatar", getAvatar());
		attributes.put("createDate", getCreateDate());
		attributes.put("songId", getSongId());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long userSongId = (Long)attributes.get("userSongId");

		if (userSongId != null) {
			setUserSongId(userSongId);
		}

		Long userId = (Long)attributes.get("userId");

		if (userId != null) {
			setUserId(userId);
		}

		Integer commentNumber = (Integer)attributes.get("commentNumber");

		if (commentNumber != null) {
			setCommentNumber(commentNumber);
		}

		Integer listenNumber = (Integer)attributes.get("listenNumber");

		if (listenNumber != null) {
			setListenNumber(listenNumber);
		}

		Integer mark = (Integer)attributes.get("mark");

		if (mark != null) {
			setMark(mark);
		}

		String recodingUrl = (String)attributes.get("recodingUrl");

		if (recodingUrl != null) {
			setRecodingUrl(recodingUrl);
		}

		String description = (String)attributes.get("description");

		if (description != null) {
			setDescription(description);
		}

		Boolean isShow = (Boolean)attributes.get("isShow");

		if (isShow != null) {
			setIsShow(isShow);
		}

		String avatar = (String)attributes.get("avatar");

		if (avatar != null) {
			setAvatar(avatar);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Long songId = (Long)attributes.get("songId");

		if (songId != null) {
			setSongId(songId);
		}
	}

	public long getUserSongId() {
		return _userSongId;
	}

	public void setUserSongId(long userSongId) {
		_userSongId = userSongId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public int getCommentNumber() {
		return _commentNumber;
	}

	public void setCommentNumber(int commentNumber) {
		_commentNumber = commentNumber;
	}

	public int getListenNumber() {
		return _listenNumber;
	}

	public void setListenNumber(int listenNumber) {
		_listenNumber = listenNumber;
	}

	public int getMark() {
		return _mark;
	}

	public void setMark(int mark) {
		_mark = mark;
	}

	public String getRecodingUrl() {
		return _recodingUrl;
	}

	public void setRecodingUrl(String recodingUrl) {
		_recodingUrl = recodingUrl;
	}

	public String getDescription() {
		return _description;
	}

	public void setDescription(String description) {
		_description = description;
	}

	public boolean getIsShow() {
		return _isShow;
	}

	public boolean isIsShow() {
		return _isShow;
	}

	public void setIsShow(boolean isShow) {
		_isShow = isShow;
	}

	public String getAvatar() {
		return _avatar;
	}

	public void setAvatar(String avatar) {
		_avatar = avatar;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public long getSongId() {
		return _songId;
	}

	public void setSongId(long songId) {
		_songId = songId;
	}

	public BaseModel<?> getUserSongsRemoteModel() {
		return _userSongsRemoteModel;
	}

	public void setUserSongsRemoteModel(BaseModel<?> userSongsRemoteModel) {
		_userSongsRemoteModel = userSongsRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			UserSongsLocalServiceUtil.addUserSongs(this);
		}
		else {
			UserSongsLocalServiceUtil.updateUserSongs(this);
		}
	}

	@Override
	public UserSongs toEscapedModel() {
		return (UserSongs)Proxy.newProxyInstance(UserSongs.class.getClassLoader(),
			new Class[] { UserSongs.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		UserSongsClp clone = new UserSongsClp();

		clone.setUserSongId(getUserSongId());
		clone.setUserId(getUserId());
		clone.setCommentNumber(getCommentNumber());
		clone.setListenNumber(getListenNumber());
		clone.setMark(getMark());
		clone.setRecodingUrl(getRecodingUrl());
		clone.setDescription(getDescription());
		clone.setIsShow(getIsShow());
		clone.setAvatar(getAvatar());
		clone.setCreateDate(getCreateDate());
		clone.setSongId(getSongId());

		return clone;
	}

	public int compareTo(UserSongs userSongs) {
		long primaryKey = userSongs.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		UserSongsClp userSongs = null;

		try {
			userSongs = (UserSongsClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = userSongs.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(23);

		sb.append("{userSongId=");
		sb.append(getUserSongId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", commentNumber=");
		sb.append(getCommentNumber());
		sb.append(", listenNumber=");
		sb.append(getListenNumber());
		sb.append(", mark=");
		sb.append(getMark());
		sb.append(", recodingUrl=");
		sb.append(getRecodingUrl());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", isShow=");
		sb.append(getIsShow());
		sb.append(", avatar=");
		sb.append(getAvatar());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", songId=");
		sb.append(getSongId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(37);

		sb.append("<model><model-name>");
		sb.append("com.mto.module.karaoke.model.UserSongs");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>userSongId</column-name><column-value><![CDATA[");
		sb.append(getUserSongId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>commentNumber</column-name><column-value><![CDATA[");
		sb.append(getCommentNumber());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>listenNumber</column-name><column-value><![CDATA[");
		sb.append(getListenNumber());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>mark</column-name><column-value><![CDATA[");
		sb.append(getMark());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>recodingUrl</column-name><column-value><![CDATA[");
		sb.append(getRecodingUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isShow</column-name><column-value><![CDATA[");
		sb.append(getIsShow());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>avatar</column-name><column-value><![CDATA[");
		sb.append(getAvatar());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songId</column-name><column-value><![CDATA[");
		sb.append(getSongId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _userSongId;
	private long _userId;
	private String _userUuid;
	private int _commentNumber;
	private int _listenNumber;
	private int _mark;
	private String _recodingUrl;
	private String _description;
	private boolean _isShow;
	private String _avatar;
	private Date _createDate;
	private long _songId;
	private BaseModel<?> _userSongsRemoteModel;
}